package com.blackline.UI.MATCH;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

/**
 * @author XBO
 * @version Jan, 2013
 * <p>This page is after clicking MATCH > Match Sets in navigation menu.
 * Please refer to UI.MatchSets.png in doc-files.
 */
public class MatchSets {
	/**
	 * Show All button
	 */
	@FindBy(id = "btnIShowAll")
	public WebElement Show_All_button;
	
	/**
	 * Add New Match Set button
	 */
	@FindBy (id = "btnMatchSet")
	public WebElement Add_New_Match_Set_button;
	
	/**
	 * Add New Adhoc Match Set button
	 */
	@FindBy(id = "btnAdhoc")
	public WebElement Add_New_Adhoc_Match_Set_button;
	
	/**
	 * Add New Match Set Group button
	 */
	@FindBy(id = "btnMatchGroup")
	public WebElement Add_New_Match_Set_Group_button;	
	
	/**
	 * Match Set search text field.
	 */
	@FindBy (id = "ctl00_ctl00_contentBody_cphMain_matchSetGridCtrl_MatchSetGrid_gvMain_filterRow_tbFilter1_MatchSetName")
	public WebElement Match_Set_text_field;
	
	
	/**
	 * Apply link
	 */
	@FindBy(id = "ctl00_ctl00_contentBody_cphMain_matchSetGridCtrl_MatchSetGrid_lbApplyFilters")
	public WebElement Apply_link;	
	
	/**
	 * Clear link
	 */
	@FindBy(id = "ctl00_ctl00_contentBody_cphMain_matchSetGridCtrl_MatchSetGrid_hlClearFilters")
	public WebElement Clear_link;
	
	/**
	 * Edit icon of the first Match Set.
	 */
	@FindBy (id = "ctl00_ctl00_contentBody_cphMain_matchSetGridCtrl_MatchSetGrid_gvMain_ctl02_ibEditView")
	public WebElement Edit_iconOf1stItem;
	
	/**
	 * Clone Match Set icon of first Match Set
	 */
	@FindBy (id = "ctl00_ctl00_contentBody_cphMain_matchSetGridCtrl_MatchSetGrid_gvMain_ctl02_ibClone")
	public WebElement Clone_Match_Set_icon;
	
	/**
	 * Click the Edit icon (the "pencil" icon) for a specific Match Set.
	 * @param matchsetName The name of the match set you want to search.
	 * <br>Sample: <br>
	 * <i>UI.MatchSets.searchAMatchSet("ASC AMEX to Chase Bank");</i>
	 */
	public void searchMatchSet (String matchsetName)
	{
		Match_Set_text_field.sendKeys(matchsetName);
		Apply_link.click();
		Edit_iconOf1stItem.click();
	}
	
	
	/**
	 * Click the Edit icon (the "pencil" icon) for a specific Match Set.
	 * @param driver The WebDriver of your test.
	 * @param matchsetName The name of the match set you want to click Edit icon.
	 * <br>Sample: <br>
	 * <i>UI.MatchSets.clickEditIconForAMatchSet(driver, "ASC AMEX to Chase Bank");</i>	 
	 **/
	public void clickEditIconForAMatchSet (WebDriver driver, String matchsetName)
	{
		WebElement element = driver.findElement(By.xpath("//td[contains(text(),'" + matchsetName + "')]/../td[1]/input"));
		element.click();
	}

}
